//
//  UserfulThreeCell.m
//  JinChengYun
//
//  Created by 金橙云 on 2017/3/20.
//  Copyright © 2017年 金橙云. All rights reserved.
//

#import "UserfulThreeCell.h"

@implementation UserfulThreeCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        _firstLab= [[UILabel alloc] init];
        _firstLab.text = @"客户姓名呀 :";
        _firstLab.font = [UIFont systemFontOfSize:14];
        _firstLab.textColor =[UIColor blackColor];
        [self addSubview:_firstLab];
        [_firstLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(90, 18));
            make.top.equalTo(self.mas_top).offset(15);
            make.left.equalTo(self.mas_left).offset(8);
        }];
        
        
        NSArray *titleArr = @[@"男",@"女"];
        for (int i = 0; i<titleArr.count; i++)
        {
            _changeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
            _changeBtn.tag = 50+i;
            _changeBtn.frame = CGRectMake(115+i*100, 13, 20, 20);
            [_changeBtn setImage:[UIImage imageNamed:@"btnSex"] forState:UIControlStateNormal];
            [_changeBtn setImage:[UIImage imageNamed:@"btnSexSele"] forState:UIControlStateSelected];
        
            if (i == 0)
            {
                _changeBtn.selected = YES;
            }
            [_changeBtn setTitleColor:[UIColor blackColor] forState:0];

            [_changeBtn addTarget:self action:@selector(changeImageBtnClick:) forControlEvents:UIControlEventTouchUpInside];
            [self addSubview:_changeBtn];
            UILabel *lab = [[UILabel alloc] initWithFrame:CGRectMake(145+i*100, 13, 20, 20)];
            lab.text = titleArr[i];
            [self addSubview:lab];
        }
       
    
        
    }
    return self;
}

- (void)setSexStr:(NSString *)sexStr {
    _sexStr = sexStr;
    UIButton *btnA =[self viewWithTag:50];
    UIButton *btnB =[self viewWithTag:51];
    if ([_sexStr isEqualToString:@"男"]) {
        btnA.selected = YES;
        btnB.selected = NO;
    }else {
        btnA.selected = NO;
        btnB.selected = YES;
    }
}

//男女的选择
-(void)changeImageBtnClick:(UIButton *)sender
{
    if (sender.tag == 50)
    {
        UIButton *btnA =[self viewWithTag:51];
        btnA.selected =NO;
        sender.selected = YES;
       
 
    }
    else
    {
        UIButton *btnA = [self viewWithTag:50];
        btnA.selected =NO;
        sender.selected = YES;
        
      
    }
    
    [self.delegate changeImageBtnClick:sender];
 

}



- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
